using GoblinXNA.Graphics;
using GoblinXNA.Graphics.Geometry;
using GoblinXNA.SceneGraph;
using Microsoft.Xna.Framework;

namespace SplashOn_PhoneLib
{
    class SplashHelper
    {        
        private static IModel splashBlobModel = null;

        static SplashHelper()
        {
            ModelLoader loader = new ModelLoader();
            splashBlobModel = loader.Load("", "blob1");                  
        }

        //public static void createSplashBloabAt(Vector3 position)
        //{
        //    createSplashBloabAt(position, AppConstants.DEFAULT_SPLASH_BLOB_COLOR);
        //}

        public static void createSplashBloabAt(TransformNode groundNode, Vector3 position, Color color)
        {
            createSplashBloabAt(groundNode, position, AppConstants.DEFAULT_BLOB_SCALE, color);
        }

        public static void createSplashBloabAt(TransformNode groundNode, Vector3 position, float scaleFactor, Color color)
        {
            TransformNode splashBlobTransformNode = new TransformNode()
            {
                Translation = position,
                Scale = new Vector3(scaleFactor),
                Rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitX, MathHelper.ToRadians(90))
            };
            GeometryNode cloneNode = new GeometryNode()
            {
                Model = splashBlobModel,
                Material = new Material
                {
                    Ambient = color.ToVector4(),
                    Diffuse = color.ToVector4(),
                    Emissive = color.ToVector4(),
                    Specular = color.ToVector4(),
                    SpecularPower = 10,
                },
            };        
   
            splashBlobTransformNode.AddChild(cloneNode);
            groundNode.AddChild(splashBlobTransformNode);
            
            GeometryNode b = new GeometryNode
            {
                Model = new Cylinder(10, 10, 10, 10),
                Material = new Material
                {
                    Ambient = color.ToVector4(),
                    Diffuse = color.ToVector4(),
                    Emissive = color.ToVector4(),
                    Specular = color.ToVector4(),
                    SpecularPower = 10,
                },
            };
            //groundNode.AddChild(b);            
        }

    }
}
